<#assign css> </#assign>
<#assign js> 
<script type="text/javascript">
$(function () {
	page.ajaxPage();
});

var selectCallBack= function(data) {
	parent['${fn}'](data);
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}
</script>
</#assign>
<#import "/admin/common/home.html" as home>
<#import "/admin/common/tree.html" as tree>
<#escape x as (x)!"">
<@home.home pagecss=css pagejs=js>
<@home.tree />
<div class="col-sm-6 col-md-6 pr0 pt10 pd10">
	<div class="main-container">
		<@tree.treeOrg treeUrl="/admin/sys/dept/selectTree">
		<#if selectType?? && selectType = 1>
			<ul class="ztree tree-box" style="overflow: auto; height: 510px;"></ul>
		</#if>
		<#if selectType?? && selectType = 2>
			<ul class="ztree tree-box" style="overflow: auto; height: 380px;"></ul>
		</#if>
		</@tree.treeOrg>
	</div>
</div>

<#if selectType?? && selectType = 1> <!-- 单选 -->
<div class="col-sm-6 col-md-6 pt10 pd10" id="pageListBox" data-url="selectList?deptCode=">
</div>
</#if>
<#if selectType?? && selectType = 2> <!-- 多选 -->
<div class="col-sm-6 col-md-6 pt10 pd10" >
	<form action="list" id="pageListForm" method="post" class="form-inline">
		<div class="search">
			<div class="form-group">
				<input type="text" name="userName" value="${param.userName}" class="form-control" placeholder="请输入姓名" />
			</div>
			<div class="form-group">
				<a href="javascript:;" class="btn btn-search " id="btn-search">查询</a>
			</div>
		</div>
		
		<div id="pageListBox" data-url="selectBatchList?deptCode=" style="overflow: auto; height: 335px;">
		</div>
	</form>
</div>

<div class="panel-footer panel-dialog-footer">
	<div class="choice-box">
		<#if selectedUsers??><#list selectedUsers as item>
			<div class="choice-item ope-color" data-id="${item.id}"><span>${item.userName}</span><a href="javascript:;" onclick="del(${item.id})" class="icon-delete">删除</a></div>
		</#list></#if>
	</div>
	<div class="text-right">
		<button id="dialog-btn-save" type="button" onclick="selectBatchUser()" class="btn btn-primary">确定</button>
		<button type="button" onclick="parent.layer.closeAll();" class="btn btn-default">取消</button>
	</div>
</div>

<script type="text/javascript">
	var initMyHtml = function() {
		$(".choice-box .choice-item").each(function() {
			var id = $(this).attr("data-id");
			$("input[data-id="+id+"]").attr("checked", true);
		});
	}
	
	var selectBatchUser = function() {
		var datas = [];
		
		$(".choice-box .choice-item").each(function() {
			var data = {};
			data.userId = $(this).attr("data-id");
			data.userName = $(this).find("span").text();
			
			datas.push(data);
		});
		
		
		selectCallBack(datas);
	}
</script>
</#if>
</@home.home>
</#escape>